package com.hziee.cosmanage.member.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;

//import org.apache.shiro.authz.annotation.RequiresPermissions;
import com.hziee.cosmanage.member.vo.UserInfoTalentVo;
import com.hziee.cosmanage.member.vo.UserInviteVo;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.hziee.cosmanage.member.entity.InviteEntity;
import com.hziee.cosmanage.member.service.InviteService;
import com.hziee.common.utils.PageUtils;
import com.hziee.common.utils.R;



/**
 * 
 *
 * @author yb
 * @email yangbin@gmail.com
 * @date 2021-02-02 22:48:30
 */
@RestController
@RequestMapping("member/invite")
public class InviteController {
    @Autowired
    private InviteService inviteService;


    /**
     * 查看所有招聘信息
     * @param cId
     * @return
     */
    @GetMapping("/getCompanyInvite/{cId}")
    public R getCompanyInvite(@PathVariable("cId") Integer cId){
        List<InviteEntity> entities = inviteService.getCompanyInvite(cId);
        return R.ok().put("data",entities);
    }

    /**
     * 向发出招聘信息的公司递交简历
     * @return
     */
    @PostMapping("/upIntroduce")
    public R upIntroduce(@RequestBody InviteEntity userInviteVo){
        boolean a = inviteService.upIntroduce(userInviteVo);
        if (a){
            return R.ok();
        }else {
            return R.error();
        }
    }

    /**
     * 部门查看招聘信息远程调用接口
     */
    @GetMapping("/getIntroduce")
    public R getIntroduce(@RequestParam("cId") Integer cId){
        List<InviteEntity> inviteEntity = (List<InviteEntity>) inviteService.getIntroduce(cId);
        return R.ok().setData(inviteEntity);
    }

    /**
     * 部门经理收到投递简历查看用户人才档案接口
     * @param uid
     * @return
     */
    @GetMapping("/checkUserInfoTalents")
    public R checkUserInfoTalents(@RequestParam("uid") Integer uid) throws ExecutionException, InterruptedException {
        UserInfoTalentVo vo = inviteService.checkUserInfoTalents(uid);
        return R.ok().put("data",vo);
    }


//    /**
//     * 列表
//     */
//    @RequestMapping("/list")
//    //@RequiresPermissions("member:invite:list")
//    public R list(@RequestParam Map<String, Object> params){
//        PageUtils page = inviteService.queryPage(params);
//
//        return R.ok().put("page", page);
//    }
//
//
//    /**
//     * 信息
//     */
//    @RequestMapping("/info/{userInviteId}")
//    //@RequiresPermissions("member:invite:info")
//    public R info(@PathVariable("userInviteId") Integer userInviteId){
//		InviteEntity invite = inviteService.getById(userInviteId);
//
//        return R.ok().put("invite", invite);
//    }
//
//    /**
//     * 保存
//     */
//    @RequestMapping("/save")
//    //@RequiresPermissions("member:invite:save")
//    public R save(@RequestBody InviteEntity invite){
//		inviteService.save(invite);
//
//        return R.ok();
//    }
//
//    /**
//     * 修改
//     */
//    @RequestMapping("/update")
//   // @RequiresPermissions("member:invite:update")
//    public R update(@RequestBody InviteEntity invite){
//		inviteService.updateById(invite);
//
//        return R.ok();
//    }
//
//    /**
//     * 删除
//     */
//    @RequestMapping("/delete")
//    //@RequiresPermissions("member:invite:delete")
//    public R delete(@RequestBody Integer[] userInviteIds){
//		inviteService.removeByIds(Arrays.asList(userInviteIds));
//
//        return R.ok();
//    }

}
